﻿@model PNProject.Core.PNUser
@{
    Layout = null;
    string avatar = string.IsNullOrEmpty(Model.Avatar) ? "/Images/Base/default-user.png" : Model.Avatar;
}
<style>
.userdetail_title
{
    color:Blue;
    font-family:Arial;
}
.userdetail_value
{
    color:#363530;
    font-weight:600;
    font-family:Arial;
    font-style:italic;
}
.userdetail_thoat
{
}
.userdetail_thoat:hover
{
    color:Red;
}
.userdetail_thoat:visited
{
    color:blue;
}
</style>
<script src="/Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<img src="@avatar" style="width:100px; height:100px; border:1px solid blue; float:left; margin-top:9px;" />
<div style="float:left; width:400px; height:100px; padding:10px;">
<span class="userdetail_title">Tên quản trị: </span><span class="userdetail_value">@Model.Name</span><br /><br />
<span class="userdetail_title">Username: </span><span class="userdetail_value">@Model.Username</span><br /><br />
<span class="userdetail_title">Email: </span><span class="userdetail_value">@Model.Email</span>
</div>

<div style="float:left; width:350px; height:100px; padding:10px;">
    <div style="text-align:right; margin-top:2px;">
    <span class="userdetail_title">Mật khẩu cũ:</span><input id="userdetail_passcu" type=password />
    </div>
    <div style="text-align:right; margin-top:2px;">
    <span class="userdetail_title">Mật khẩu mới:</span><input id="userdetail_passmoi" type=password />
    </div>
    <div style="text-align:right; margin-top:2px;">
    <span class="userdetail_title">Nhập lại mật khẩu:</span><input id="userdetail_passmoilai" type=password />
    </div>
    <div style="text-align:right; margin-top:2px;">
   <button style="color:Red; width:142px; height:30px;" id="thaydoi_pass">Thay đổi mật khẩu</button>
    </div>
</div>
<div style="float:right; width:50px; height:100px; padding:10px;">
<br />
<br />
<a class="userdetail_thoat" href="/account/logoff">Thoát</a>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $(thaydoi_pass).click(function () {
            var pwc = $(userdetail_passcu).val();
            var pwn = $(userdetail_passmoi).val();
            var pwr = $(userdetail_passmoilai).val();
            if (pwc.length < 6 || (pwn != pwr) || pwn.length < 6)
                alert("Nhập không đúng");
            else {
                $.ajax({
                    url: "/api/MemberAPI/ChangePassword?pw_c="+pwc+"&pw_n="+pwn+"&pw_r="+pwr,
                }).done(function (data) {
                    if(data=="ok")
                    alert("Đổi mật khẩu thành công");
                    else
                    alert("Đổi mật khẩu thất bại");
                });
            }
            $(userdetail_passcu).val("");
            $(userdetail_passmoi).val("");
            $(userdetail_passmoilai).val("");
        });
    });
</script>
